package com.eascs.ticket.schedule.controller;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.eascs.common.util.ObjectUtil;
import com.eascs.site.controller.BaseRestController;
import com.eascs.site.view.BaseRestResult;
import com.eascs.site.view.HtmlRestResult;
import com.eascs.site.view.ViewContext;
import com.eascs.ticket.common.entity.EntityUtil;
import com.eascs.ticket.common.form.IdForm;
import com.eascs.ticket.schedule.entity.ScheduleTicketOperator;
import com.eascs.ticket.schedule.form.SaveScheduleTicketOperatorForm;
import com.eascs.ticket.schedule.service.ScheduleTicketOperatorService;

@RestController
public class ScheduleTicketOperatorRestController extends BaseRestController {

	@Inject
	private ScheduleTicketOperatorService scheduleTicketOperatorService;

	@RequestMapping(value = "/schedule/rest/saveScheduleTicketOperator")
	public BaseRestResult<String> saveScheduleTicketOperator(SaveScheduleTicketOperatorForm saveScheduleTicketOperatorForm) {
		ScheduleTicketOperator scheduleTicketOperator = new ScheduleTicketOperator();
		ObjectUtil.copySimpleProperties(saveScheduleTicketOperatorForm, scheduleTicketOperator);
		EntityUtil.initInsertEntity(scheduleTicketOperator);
		scheduleTicketOperatorService.insertScheduleTicketOperator(scheduleTicketOperator);
		return BaseRestResult.refresh();
	}

	@RequestMapping(value = "/schedule/rest/removeScheduleTicketOperator")
	public BaseRestResult<String> removeScheduleTicketOperator(IdForm idForm) {
		scheduleTicketOperatorService.removeScheduleTicketOperator(idForm.getId());
		return BaseRestResult.refresh();
	}

	@RequestMapping(value = "/schedule/rest/getScheduleTicketOperatorEdit")
	public HtmlRestResult getScheduleTicketOperatorEdit(IdForm scheduleTicketIdForm) {
		ViewContext.put("scheduleTicketId", scheduleTicketIdForm.getId());
		return HtmlRestResult.popHtmlFragment("/schedule/getScheduleTicketOperatorEdit");
	}

}
